﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
using ConnectionControl;
using System.Net;

namespace pokerServer
{
	public partial class ServerConsole : Form
	{
		private Server s;
		public ServerConsole()
		{
			InitializeComponent();
			progressBar1.Style = ProgressBarStyle.Marquee;
			progressBar1.MarqueeAnimationSpeed = 0;
			this.userCount.Text = 0 + "";
			btnStop.Enabled = false;
		}

		private void btnStop_Click(object sender, EventArgs e)
		{
			s.shutDown();
			btnStart.Enabled = true;
			btnStop.Enabled = false;
			progressBar1.MarqueeAnimationSpeed = 0;
			this.userList.Items.Clear();
			this.userCount.Text = 0 + "";

		}

		private void btnStart_Click(object sender, EventArgs e)
		{
			
			s = new Server(IPAddress.Parse("192.168.1.190"), this.reportBox, this.userCount,this.conUserBox, this.userList);
			s.start();
			btnStart.Enabled = false;
			btnStop.Enabled = true;
			progressBar1.MarqueeAnimationSpeed = 30;

		}

		private void ServerConsole_FormClosing(object sender, FormClosingEventArgs e) {
			s.shutDown();
		}

	}
	public class Wind32
	{
		[DllImport("kernel32.dll")]
		public static extern Boolean AllocConsole();
		[DllImport("kernel32.dll")]
		public static extern Boolean FreeConsole();
	}	
}

